package com.example.demo.service;

import com.example.demo.entity.Articleinfo;
import com.example.demo.entity.Userinfo;
import com.example.demo.mapper.ArticleMapper;
import com.example.demo.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

@Service
public class ArticleService implements Serializable {
    @Resource
    public ArticleMapper articleMapper;
    @Resource
    public UserMapper userMapper;

    //获取左侧个人信息的文章个数
    public int getArtCountByid(Integer uid){
        return articleMapper.getArtCountByid(uid);
    }


    //获取右侧信息框
    public List<Articleinfo> getMyList(Integer uid){
        return articleMapper.getMyList(uid);
    }

    //删除文章
    public int del(Integer id,Integer uid){
        return articleMapper.del(id,uid);
    }

    //查看全文
    public Articleinfo getDetail(Integer id){
        return articleMapper.getDetail(id);
    }

    //增加文章阅读量
    public int increamentRCount(Integer id){
        return articleMapper.incrementRCount(id);
    }

    //添加文章
    public int add(Articleinfo articleinfo){
        return articleMapper.add(articleinfo);
    }

    //修改文章
    public int update(Articleinfo articleinfo){
        return articleMapper.update(articleinfo);
    }

    //分页显示文章列表页
    public List<Articleinfo> getListByPage(Integer psize,Integer offsize){
        return articleMapper.getListByPage(psize,offsize);
    }

    //返回数据库中的数据个数
    public Integer getcount(){
        return articleMapper.getcount();
    }

    //保存文章草稿
    public Integer addsave(Articleinfo articleinfo){
        return articleMapper.addsave(articleinfo);
    }

    //获取个人所有保存的草稿
    public List<Articleinfo> getMyListSave(Integer id){
        return articleMapper.getMyListSave(id);
    }

    //返回个人草稿总条数
    public int getArtSaveCountByid(Integer uid){
        return articleMapper.getArtSaveCountByid(uid);
    }

    //返回搜索框的内容
    public List<Articleinfo> getSearch(Integer psize,Integer offsize,String title){
        return articleMapper.getSearch(psize, offsize, title);
    }
}
